package org.dey.controller;

import org.dey.entity.Result;
import org.dey.pojo.HealthAssessment;
import org.dey.pojo.Member;
import org.dey.pojo.PageVo;
import org.dey.service.HealthAssessmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class HealthAssessmentController {
    @Autowired
    HealthAssessmentService healthAssessmentService;

    @PostMapping("queryHa.do/{pageNum}/{pageSize}")
    public PageVo<HealthAssessment> queryHa(@RequestBody HealthAssessment healthAssessment,
                                            @PathVariable int pageNum,
                                            @PathVariable int pageSize) {

        PageVo<HealthAssessment> healthAssessmentPageVo = healthAssessmentService.queryHa(healthAssessment, pageNum, pageSize);
        return healthAssessmentPageVo;
    }

    //增
    @PostMapping("addha.do")
    public Result addHa(@RequestBody HealthAssessment healthAssessment){

        return healthAssessmentService.addHa(healthAssessment);
    }


    //删
    @DeleteMapping("delha.do/{id}")
    public Result deleteRa(@PathVariable int id) {
        Result result = healthAssessmentService.delHa(id);
        return result;
    }

    //修改前先根据id查到该数据
    @GetMapping("haid.do/{haid}")
    public HealthAssessment queryHaByid(@PathVariable int haid){
        HealthAssessment queryHaByid = healthAssessmentService.queryHaByid(haid);
        return queryHaByid;
    }

    //根据id修改
    @PutMapping("updateha.do")
    public int updateHa(@RequestBody HealthAssessment healthAssessment){

        return healthAssessmentService.updateHa(healthAssessment);
    }

    @GetMapping("queryTorList.do")
    public List<Member> queryTorList(){
        return healthAssessmentService.queryTorList();
    }



}
